#include "ModelObject.h"



ModelObject::ModelObject (Model * pModel) : _pModel (pModel)//, _pMaterial (NULL)
{

}

ModelObject::~ModelObject ()
{
	delete _pModel;
}

Model * ModelObject::getModel ()
{
	return _pModel;
}

const Model * ModelObject::getModel () const
{
	return _pModel;
}

// void ModelObject::setMaterial (Material * pMaterial)
// {
// 	_pMaterial = pMaterial;
// }
// 
// Material * ModelObject::getMaterial ()
// {
// 	return _pMaterial;
// }
// 
// const Material * ModelObject::getMaterial () const
// {
// 	return _pMaterial;
// }

void ModelObject::render ()
{
}

void ModelObject::_applyRotateMatrix ()
{
	glm::mat4 rotateMat = getPreviewRotateMatrix ();
	for (int i = 0; i < _pModel->getVertexCount (); ++i) {
		_pModel->setVertex (i, (rotateMat *
			glm::vec4 (_pModel->getVertices ()[i], 1.0)).
			swizzle (glm::X, glm::Y, glm::Z));
	}
}

void ModelObject::_applyScaleMatrix ()
{
	glm::mat4 scaleMat = getPreviewScaleMatrix ();
	for (int i = 0; i < _pModel->getVertexCount (); ++i) {
		_pModel->setVertex (i, (scaleMat *
			glm::vec4 (_pModel->getVertices ()[i], 1.0)).
			swizzle (glm::X, glm::Y, glm::Z));
	}
}